package com.hui10.mediaplayer.ui.activity

import android.support.v7.widget.Toolbar
import com.hui10.mediaplayer.R
import com.hui10.mediaplayer.base.BaseActivity
import com.hui10.mediaplayer.util.FragmentUtil
import com.hui10.mediaplayer.util.ToolBarManager
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.toolbar.*

class MainActivity : BaseActivity(), ToolBarManager {
    override val mToolBar: Toolbar by lazy {
        toolbar
    }

    private val mBottomBar by lazy {
        bottomBar
    }

    override fun getLayoutId(): Int {
        return R.layout.activity_main
    }

    override fun initData() {
        super.initData()
        initMainToolBar()
    }

    override fun initListener() {
        super.initListener()
        mBottomBar.setOnTabSelectListener {
            val transaction = supportFragmentManager.beginTransaction()
            FragmentUtil.get().getFragmentById(it)?.let { fag ->
                transaction.replace(
                    R.id.container,
                    fag, it.toString()
                )
            }
            transaction.commit()
        }
    }

}
